package com.tz.online.order.action;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.tz.online.entity.Pageing;
import com.tz.online.entity.User;
import com.tz.online.order.service.IOrderService;
import com.tz.online.util.BeanFactory;

/**
 * 根据用户查看订单
 * @author Administrator
 *
 */
@WebServlet(name="orderList",urlPatterns="/permission/order/list")
public class OrderListAction extends HttpServlet {
	/**
	 * 
	 */
	private static final long serialVersionUID = 5436727636413319553L;
	IOrderService os = (IOrderService)BeanFactory.getBean("orderService");
	
	@Override
	protected void service(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		User user = (User) req.getSession().getAttribute("userInfo");
		
		//接收分页条件
		String pageNow = req.getParameter("pageNow");
		String pageSize = req.getParameter("pageSize");
		
		//如果没有接收到，给予默认
		pageNow = pageNow==null?"1":pageNow;
		pageSize = pageSize==null?"6":pageSize;
		
		Pageing paging = os.queryOrderByPage(user, Integer.parseInt(pageSize), Integer.parseInt(pageNow));
		
		req.setAttribute("paging", paging);
		
		req.getRequestDispatcher("/jsp/order/orderlist.jsp").forward(req, resp);
	}

}
